home *** CD-ROM | disk | FTP | other *** search
/ Euroscene 2 / Euroscene 2.iso / USEFUL / DeliTracker130 / Developer / Developer.run / Examples / Delta1.0.s next >
Encoding:
Text File  |  1992-09-23  |  17.2 KB  |  884 lines

  1.  
  2.     incdir    "Includes:"
  3.     include    "misc/DeliPlayer.i"
  4.  
  5. ;
  6. ;
  7.     SECTION Player,Code
  8. ;
  9. ;
  10.  
  11.     PLAYERHEADER PlayerTagArray
  12.  
  13.     dc.b '$VER: Delta Music 1.0 player module V1.0 (02 Sep 92)',0
  14.     even
  15.  
  16. PlayerTagArray
  17.     dc.l    DTP_PlayerVersion,0
  18.     dc.l    DTP_PlayerName,PName
  19.     dc.l    DTP_Creator,CName
  20.     dc.l    DTP_Check2,Chk
  21.     dc.l    DTP_Interrupt,DM_play
  22.     dc.l    DTP_InitPlayer,InitPlay
  23.     dc.l    DTP_EndPlayer,EndPlay
  24.     dc.l    DTP_InitSound,InitSnd
  25.     dc.l    DTP_EndSound,RemSnd
  26.     dc.l    TAG_DONE
  27.  
  28. *-----------------------------------------------------------------------*
  29. ;
  30. ; Player/Creatorname und lokale Daten
  31.  
  32. PName    dc.b 'DeltaMusic_1.0',0
  33. CName    dc.b 'Bent Nielsen,',10
  34.     dc.b 'adapted by Delirium',0
  35.     even
  36. DM_data        dc.l 0
  37.  
  38. *-----------------------------------------------------------------------*
  39. ;
  40. ; Testet auf DeltaMusic1.0-Modul
  41.  
  42. Chk
  43.     move.l    dtg_ChkData(a5),a0
  44.     move.l    (a0),d0
  45.     subi.l    #"ALL ",d0
  46.     rts
  47.  
  48. *-----------------------------------------------------------------------*
  49. ;
  50. ; Init Player
  51.  
  52. InitPlay
  53.     moveq    #0,d0
  54.     move.l    dtg_GetListData(a5),a0        ; Function
  55.     jsr    (a0)
  56.     move.l    a0,DM_data
  57.  
  58.     move.l    dtg_AudioAlloc(a5),a0        ; Function
  59.     jsr    (a0)                ; returncode is already set !
  60.     rts
  61.  
  62. *-----------------------------------------------------------------------*
  63. ;
  64. ; End Player
  65.  
  66. EndPlay
  67.     move.l    dtg_AudioFree(a5),a0        ; Function
  68.     jsr    (a0)
  69.     rts
  70.  
  71. *-----------------------------------------------------------------------*
  72.  
  73. ; Init Sound
  74.  
  75. InitSnd
  76.     jsr    DM_init                ; Init Sound
  77.     rts
  78.  
  79. *-----------------------------------------------------------------------*
  80. ;
  81. ; Remove Sound
  82.  
  83. RemSnd
  84.     lea    $dff000,a0
  85.     moveq    #0,d0
  86.     move.w    d0,$a8(a0)
  87.     move.w    d0,$b8(a0)
  88.     move.w    d0,$c8(a0)
  89.     move.w    d0,$d8(a0)
  90.     move.w    #$000F,$96(a0)            ; End Sound
  91.     rts
  92.  
  93. *-----------------------------------------------------------------------*
  94. ;
  95. ; Delta_1.0-Repaly
  96.  
  97. ;
  98. ;
  99.     SECTION Replay,Code_C
  100. ;
  101. ;
  102.  
  103. ; -------------------------------------------
  104. ; ----      DELTA MUSIC REPLAY V1.0      ----
  105. ; ----      ~~~~~~~~~~~~~~~~~~~~~~~      ----
  106. ; ----                                   ----
  107. ; ----  coded by : Bent Nielsen (SHOGUN) ----
  108. ; ----             Kyradservej 19B       ----
  109. ; ----             8700 Horsens          ----
  110. ; ----             Denmark               ----
  111. ; ----       tlf.  75-601-868            ----
  112. ; -------------------------------------------
  113. ; ---- contact me if you want the editor ----
  114. ; ---- sources coded .........           ----
  115. ; -------------------------------------------
  116.  
  117. speed = 6    ; play speed
  118.  
  119. ; ////  hardware  \\\\
  120. h_sound     = 0
  121. h_length    = 4
  122. h_frequency = 6
  123. h_volume    = 8
  124.  
  125. ; ////  instrument  \\\\
  126. s_attack_step     = 0
  127. s_attack_delay    = 1
  128. s_decay_step      = 2
  129. s_decay_delay     = 3
  130. s_sustain         = 4
  131. s_release_step    = 6
  132. s_release_delay   = 7
  133. s_volume          = 8
  134. s_vibrator_wait   = 9
  135. s_vibrator_step   = 10
  136. s_vibrator_length = 11
  137. s_bendrate        = 12
  138. s_portamento      = 13
  139. s_sample          = 14
  140. s_table_delay     = 15
  141. s_arpeggio        = 16
  142. s_sound_length    = 24
  143. s_repeat          = 26
  144. s_repeat_length   = 28
  145. s_table           = 30
  146. s_sounddata       = 78
  147.  
  148. ; ////  channel  \\\\
  149. c_hardware        = 0
  150. c_dma             = 4
  151. c_sounddata       = 6
  152. c_frequency       = 10
  153. c_sound_table     = 12
  154. c_sound_table_cnt = 16
  155. c_sound_table_del = 17
  156. c_track           = 18
  157. c_track_cnt       = 22
  158. c_block           = 24
  159. c_block_cnt       = 28
  160. c_vibrator_wait   = 32
  161. c_vibrator_length = 33
  162. c_vibrator_pos    = 34
  163. c_vibrator_cmp    = 35
  164. c_vibrator_freq   = 36
  165. c_old_frequency   = 38
  166. c_frequency_data  = 40
  167. c_actual_volume   = 41
  168. c_attack_delay    = 42
  169. c_decay_delay     = 43
  170. c_sustain         = 44
  171. c_release_delay   = 46
  172. c_play_speed      = 47
  173. c_bendrate_freq   = 48
  174. c_transpose       = 50
  175. c_status          = 51
  176. c_arpeggio_cnt    = 52
  177. c_arpeggio_data   = 53
  178. c_arpeggio_on     = 54
  179. c_effect_number   = 55
  180. c_effect_data     = 56
  181. ; next 57
  182.  
  183. DM_play:
  184.     movem.l    d0-d7/a0-a6,-(a7)
  185.     lea    channel1(pc),a6
  186.     bsr    DM_calc_frequency
  187.     lea    channel2(pc),a6
  188.     bsr    DM_calc_frequency
  189.     lea    channel3(pc),a6
  190.     bsr    DM_calc_frequency
  191.     lea    channel4(pc),a6
  192.     bsr    DM_calc_frequency
  193.  
  194.     move.w    #$800f,$dff096
  195. DM_sample_handler:
  196.     move.w    #200,d0
  197. DM_swait:
  198.     dbra    d0,DM_swait
  199.  
  200.     lea    channel1(pc),a6
  201.     move.l    c_hardware(a6),a4
  202.     move.l    c_sounddata(a6),a5
  203.     tst.b    s_sample(a5)
  204.     beq.s    DM_no_sample1
  205.     move.w    s_repeat_length(a5),h_length(a4)
  206.     moveq    #0,d7
  207.     move.w    s_repeat(a5),d7
  208.     add.l    a5,d7
  209.     add.l    #s_table,d7
  210.     move.l    d7,h_sound(a4)
  211. DM_no_sample1:
  212.  
  213.     lea    channel2(pc),a6
  214.     move.l    c_hardware(a6),a4
  215.     move.l    c_sounddata(a6),a5
  216.     tst.b    s_sample(a5)
  217.     beq.s    DM_no_sample2
  218.     move.w    s_repeat_length(a5),h_length(a4)
  219.     moveq    #0,d7
  220.     move.w    s_repeat(a5),d7
  221.     add.l    a5,d7
  222.     add.l    #s_table,d7
  223.     move.l    d7,h_sound(a4)
  224. DM_no_sample2:
  225.  
  226.     lea    channel3(pc),a6
  227.     move.l    c_hardware(a6),a4
  228.     move.l    c_sounddata(a6),a5
  229.     tst.b    s_sample(a5)
  230.     beq.s    DM_no_sample3
  231.     move.w    s_repeat_length(a5),h_length(a4)
  232.     moveq    #0,d7
  233.     move.w    s_repeat(a5),d7
  234.     add.l    a5,d7
  235.     add.l    #s_table,d7
  236.     move.l    d7,h_sound(a4)
  237. DM_no_sample3:
  238.  
  239.     lea    channel4(pc),a6
  240.     move.l    c_hardware(a6),a4
  241.     move.l    c_sounddata(a6),a5
  242.     tst.b    s_sample(a5)
  243.     beq.s    DM_no_sample4
  244.     move.w    s_repeat_length(a5),h_length(a4)
  245.     moveq    #0,d7
  246.     move.w    s_repeat(a5),d7
  247.     add.l    a5,d7
  248.     add.l    #s_table,d7
  249.     move.l    d7,h_sound(a4)
  250. DM_no_sample4:
  251.     movem.l    (a7)+,d0-d7/a0-a6
  252.     rts
  253.  
  254.  
  255. DM_calc_frequency:
  256.     move.l    c_hardware(a6),a4
  257.     move.l    c_sounddata(a6),a5
  258.  
  259.     subq.b    #1,c_play_speed(a6)
  260.     bne    DM_block_con
  261.     move.b    play_speed,c_play_speed(a6)
  262.  
  263.     tst.l    c_block_cnt(a6)
  264.     bne.s    DM_check_block
  265. DM_track_step:
  266.     move.l    c_track(a6),a0
  267.     move.w    c_track_cnt(a6),d7
  268.     move.w    (a0,d7.w),d0
  269.     cmp.w    #-1,d0
  270.     bne.s    DM_track_con
  271.     move.w    2(a0,d7.w),d0
  272.     and.w    #$7ff,d0
  273.     asl.w    #1,d0
  274.     move.w    d0,c_track_cnt(a6)
  275.     bra.s    DM_track_step
  276. DM_track_con:
  277.     move.b    d0,c_transpose(a6)
  278.     asr.l    #2,d0
  279.     and.l    #%00000000000000000011111111000000,d0
  280.     add.l    blocks(pc),d0
  281.     move.l    d0,c_block(a6)
  282.     addq.w    #2,c_track_cnt(a6)
  283.  
  284. DM_check_block:
  285.     move.l    c_block(a6),a0
  286.     add.l    c_block_cnt(a6),a0
  287.  
  288.     tst.b    2(a0)
  289.     beq.s    DM_no_new_effect
  290.     move.b    2(a0),c_effect_number(a6)
  291.     move.b    3(a0),c_effect_data(a6)
  292.  
  293. DM_no_new_effect:
  294.     moveq    #0,d0
  295.     move.b    1(a0),d0
  296.     beq    DM_test_effect
  297.     add.b    c_transpose(a6),d0
  298.     move.b    d0,c_frequency_data(a6)
  299.  
  300.     move.w    c_dma(a6),d0
  301.     sub.w    #$8000,d0
  302.     move.w    d0,$dff096
  303.  
  304.     moveq    #0,d0
  305.     move.b    d0,c_status(a6)
  306.     move.w    d0,c_bendrate_freq(a6)
  307.     move.w    d0,c_arpeggio_cnt(a6)
  308.     move.b    d0,c_arpeggio_on(a6)
  309.  
  310.     move.b    2(a0),c_effect_number(a6)
  311.     move.b    3(a0),c_effect_data(a6)
  312.  
  313.     lea    snd_table(pc),a1
  314.     move.b    (a0),d0
  315.     asl.l    #2,d0
  316.     move.l    (a1,d0.l),d0
  317.     move.l    d0,c_sounddata(a6)
  318.  
  319.     move.l    d0,a5
  320.     add.l    #s_table,d0
  321.     move.l    d0,c_sound_table(a6)
  322.     clr.b    c_sound_table_cnt(a6)
  323.     tst.b    s_sample(a5)
  324.     beq.s    DM_no_sample_clear
  325.     clr.w    s_table(a5)
  326.     move.l    d0,h_sound(a4)
  327. DM_no_sample_clear:
  328.  
  329.     move.w    s_sound_length(a5),d0
  330.     asr.w    #1,d0
  331.     move.w    d0,h_length(a4)
  332.  
  333.     move.b    s_vibrator_wait(a5),c_vibrator_wait(a6)
  334.     move.b    s_vibrator_length(a5),d0
  335.     move.b    d0,c_vibrator_length(a6)
  336.     move.b    d0,c_vibrator_pos(a6)
  337.     asl.b    #1,d0
  338.     move.b    d0,c_vibrator_cmp(a6)
  339.     clr.b    c_actual_volume(a6)
  340.     clr.b    c_sound_table_del(a6)
  341.     clr.b    c_sound_table_cnt(a6)
  342.     clr.b    c_attack_delay(a6)
  343.     clr.b    c_decay_delay(a6)
  344.     move.w    s_sustain(a5),c_sustain(a6)
  345.     clr.b    c_release_delay(a6)
  346.  
  347. DM_test_effect:
  348.     addq.l    #4,c_block_cnt(a6)
  349.     cmp.l    #64,c_block_cnt(a6)
  350.     bne.s    DM_block_con
  351.     clr.l    c_block_cnt(a6)
  352. DM_block_con:
  353.  
  354.     tst.b    s_sample(a5)
  355.     bne.s    DM_portamento_handler
  356.     tst.b    c_sound_table_del(a6)
  357.     beq.s    DM_sound_table_handler
  358.     subq.b    #1,c_sound_table_del(a6)
  359.     bra.s    DM_portamento_handler
  360.  
  361. DM_sound_table_handler:
  362.     move.b    s_table_delay(a5),c_sound_table_del(a6)
  363.  
  364. DM_sound_read_again:
  365.     move.l    c_sound_table(a6),a0
  366.     moveq    #0,d6
  367.     move.b    c_sound_table_cnt(a6),d6
  368.     cmp.b    #48,d6
  369.     bmi.s    DM_sound_read_c
  370.     clr.b    c_sound_table_cnt(a6)
  371.     moveq    #0,d6
  372. DM_sound_read_c:
  373.     add.l    d6,a0
  374.     moveq    #0,d7
  375.     move.b    (a0),d7
  376.  
  377.     bpl.s    DM_new_sounddata
  378.     cmp.b    #$ff,d7
  379.     bne.s    DM_sound_new_speed
  380.     move.b    1(a0),d7
  381.     move.b    d7,c_sound_table_cnt(a6)
  382.     bra.s    DM_sound_read_again
  383. DM_sound_new_speed:
  384.     and.b    #127,d7
  385.     move.b    d7,s_table_delay(a5)    
  386.     addq.b    #1,c_sound_table_cnt(a6)
  387.     bra.s    DM_sound_read_again
  388.  
  389. DM_new_sounddata:
  390.     asl.l    #5,d7
  391.     add.l    #s_sounddata,d7
  392.     add.l    c_sounddata(a6),d7
  393.     move.l    d7,h_sound(a4)        ; Set hardware sound data
  394.     addq.b    #1,c_sound_table_cnt(a6)
  395.  
  396. DM_portamento_handler:
  397.     tst.b    s_portamento(a5)
  398.     beq.s    DM_vibrator_handler
  399.     move.w    c_frequency(a6),d1
  400.     bne.s    DM_porta_con
  401.     moveq    #0,d0
  402.     lea    freq_table(pc),a1
  403.     move.b    c_frequency_data(a6),d0
  404.     asl.w    #1,d0
  405.     move.w    (a1,d0.w),d0
  406.     add.w    c_bendrate_freq(a6),d0
  407.     move.w    d0,c_frequency(a6)
  408.     bra.s    DM_vibrator_handler
  409.  
  410. DM_porta_con:
  411.     moveq    #0,d0
  412.     moveq    #0,d2
  413.     move.b    s_portamento(a5),d2
  414.     lea    freq_table(pc),a1
  415.     move.b    c_frequency_data(a6),d0
  416.     asl.w    #1,d0
  417.     move.w    (a1,d0.w),d0
  418.     add.w    c_bendrate_freq(a6),d0
  419.     cmp.w    d0,d1
  420.     beq.s    DM_vibrator_handler
  421.     blo.s    DM_porta_low
  422.     sub.w    d2,d1
  423.     cmp.w    d0,d1
  424.     bpl.s    DM_porta_high_con
  425.     move.w    d0,c_frequency(a6)
  426.     bra.s    DM_vibrator_handler
  427. DM_porta_high_con:
  428.     move.w    d1,c_frequency(a6)
  429.     bra.s    DM_vibrator_handler
  430. DM_porta_low:
  431.     add.w    d2,d1
  432.     cmp.w    d0,d1
  433.     bmi.s    DM_porta_low_con
  434.     move.w    d0,c_frequency(a6)
  435.     bra.s    DM_vibrator_handler
  436. DM_porta_low_con:
  437.     move.w    d1,c_frequency(a6)
  438.  
  439.  
  440. DM_vibrator_handler:
  441.     tst.b    c_vibrator_wait(a6)
  442.     beq.s    DM_calc_vibrator
  443.     subq.b    #1,c_vibrator_wait(a6)
  444.     bra.s    DM_bendrate_handler
  445. DM_calc_vibrator:
  446.     moveq    #0,d0
  447.     moveq    #0,d1
  448.     move.b    c_vibrator_pos(a6),d0
  449.     move.b    d0,d2
  450.     move.b    s_vibrator_step(a5),d1
  451.     mulu    d1,d0
  452.     move.w    d0,c_vibrator_freq(a6)
  453.  
  454.     btst    #0,c_status(a6)
  455.     bne.s    DM_vibrator_minus
  456. DM_vibrator_plus:
  457.     addq.b    #1,d2
  458.     cmp.b    c_vibrator_cmp(a6),d2
  459.     bne.s    DM_vibrator_no_reset
  460.     eor.b    #1,c_status(a6)
  461. DM_vibrator_no_reset:
  462.     move.b    d2,c_vibrator_pos(a6)
  463.     bra.s    DM_bendrate_handler
  464.  
  465. DM_vibrator_minus:
  466.     subq.b    #1,d2
  467.     bne.s    DM_vibrator_no_reset2
  468.     eor.b    #1,c_status(a6)
  469. DM_vibrator_no_reset2:
  470.     move.b    d2,c_vibrator_pos(a6)
  471.  
  472. DM_bendrate_handler:
  473.     moveq    #0,d0
  474.     move.l    c_sounddata(a6),a1
  475.     move.b    s_bendrate(a1),d0
  476.     bpl.s    DM_rate_minus
  477.     neg.b    d0
  478.  
  479.     add.w    d0,c_bendrate_freq(a6)
  480.     bra.s    DM_effect_handler
  481.  
  482. DM_rate_minus:
  483.     sub.w    d0,c_bendrate_freq(a6)
  484.  
  485. DM_effect_handler:
  486.     moveq    #0,d0
  487.     moveq    #0,d1
  488.     move.b    c_effect_data(a6),d0
  489.     move.b    c_effect_number(a6),d1
  490.     lea    effect_table(pc),a1
  491.     and.b    #$1f,d1
  492.     asl.l    #2,d1
  493.     move.l    (a1,d1.w),a1
  494.     jsr    (a1)
  495.  
  496. DM_arpeggio_handler:
  497.     move.l    a5,a1
  498.     add.l    #s_arpeggio,a1
  499.     moveq    #0,d0
  500.     move.b    c_arpeggio_cnt(a6),d0
  501.     move.b    (a1,d0.w),d1
  502.     addq.b    #1,c_arpeggio_cnt(a6)
  503.     and.b    #%00000111,c_arpeggio_cnt(a6)
  504.  
  505. DM_store_frequency:
  506.     lea    freq_table(pc),a1
  507.     move.b    c_frequency_data(a6),d0
  508.     add.b    d1,d0
  509.     asl.w    #1,d0
  510.     move.w    (a1,d0.l),d0
  511.  
  512.     moveq    #0,d1
  513.     moveq    #0,d2
  514.     move.b    c_vibrator_length(a6),d1
  515.     move.b    s_vibrator_step(a5),d2
  516.     mulu    d2,d1
  517.     sub.w    d1,d0
  518.     add.w    c_bendrate_freq(a6),d0
  519.     tst.b    s_portamento(a5)
  520.     beq.s    DM_store_no_port
  521.     move.w    c_frequency(a6),d0
  522.     bra.s    DM_store_port
  523. DM_store_no_port:
  524.     clr.w    c_frequency(a6)
  525. DM_store_port:
  526.     add.w    c_vibrator_freq(a6),d0
  527.     move.w    d0,h_frequency(a4)
  528.  
  529. DM_volume_handler:
  530.     moveq    #0,d1        ; actual volume
  531.     move.b    c_actual_volume(a6),d1
  532.  
  533.     move.b    c_status(a6),d0
  534.     and.b    #%00001110,d0
  535.  
  536.     tst.b    d0
  537.     bne.s    DM_test_decay
  538.  
  539.     tst.b    c_attack_delay(a6)
  540.     beq.s    DM_attack_handler
  541.     subq.b    #1,c_attack_delay(a6)
  542.     bra    DM_volume_exit
  543. DM_attack_handler:
  544.     move.b    s_attack_delay(a5),c_attack_delay(a6)
  545.     add.b    s_attack_step(a5),d1
  546.     cmp.b    #64,d1
  547.     blo.s    DM_attack_con
  548.     or.b    #%00000010,d0
  549.     or.b    #%00000010,c_status(a6)
  550.     move.b    #64,d1
  551. DM_attack_con:
  552.  
  553.  
  554. DM_test_decay:
  555.     cmp.b    #%00000010,d0
  556.     bne.s    DM_test_sustain
  557.  
  558.     tst.b    c_decay_delay(a6)
  559.     beq.s    DM_decay_handler
  560.     subq.b    #1,c_decay_delay(a6)
  561.     bra.s    DM_volume_exit
  562. DM_decay_handler:
  563.     move.b    s_decay_delay(a5),c_decay_delay(a6)
  564.     move.b    s_volume(a5),d2
  565.     sub.b    s_decay_step(a5),d1
  566.     cmp.b    d2,d1
  567.     bhi.s    DM_decay_con
  568.     move.b    s_volume(a5),d1
  569.     or.b    #%00000110,d0
  570.     or.b    #%00000110,c_status(a6)
  571. DM_decay_con:
  572.  
  573. DM_test_sustain:
  574.     cmp.b    #%00000110,d0
  575.     bne.s    DM_test_release
  576.  
  577.     tst.w    c_sustain(a6)
  578.     beq.s    DM_sustain_handler
  579.     subq.w    #1,c_sustain(a6)
  580.     bra.s    DM_volume_exit
  581. DM_sustain_handler:
  582.     or.b    #%00001110,d0
  583.     or.b    #%00001110,c_status(a6)
  584.  
  585. DM_test_release:
  586.     cmp.b    #%00001110,d0
  587.     bne.s    DM_volume_exit
  588.  
  589.     tst.b    c_release_delay(a6)
  590.     beq.s    DM_release_handler
  591.     subq.b    #1,c_release_delay(a6)
  592.     bra.s    DM_volume_exit
  593. DM_release_handler:
  594.     move.b    s_release_delay(a5),c_release_delay(a6)
  595.     sub.b    s_release_step(a5),d1
  596.     bpl.s    DM_release_con
  597.     and.b    #%00001001,c_status(a6)
  598.     moveq    #0,d1
  599. DM_release_con:
  600.  
  601. DM_volume_exit:
  602.     move.b    d1,c_actual_volume(a6)
  603.  
  604.     move.w    d1,h_volume(a4)
  605.     rts
  606.  
  607.  
  608. ; ----  INIT MUSIC  ----
  609.  
  610. all_check = 0
  611. trk1      = 4
  612.  
  613.  
  614. DM_init:
  615.     move.l    DM_data,a0
  616.     lea    26*4(a0),a0
  617.     lea    track1(pc),a1
  618.     moveq    #24,d7
  619. DM_init_loop:
  620.     move.l    a0,(a1)+
  621.     dbra    d7,DM_init_loop
  622.  
  623.     moveq    #23,d6
  624.     lea    track1+(24*4)(pc),a1
  625. DM_init_loop2:
  626.     move.l    DM_data,a0
  627.     lea    4(a0),a0
  628.     move.l    d6,d7
  629. DM_init_loop3:
  630.     move.l    (a0)+,d0
  631.     add.l    d0,(a1)
  632.     dbra    d7,DM_init_loop3
  633.     subq.l    #4,a1
  634.     dbra    d6,DM_init_loop2
  635.  
  636.     lea    $dff0a0,a0
  637.     lea    channel1(pc),a6
  638.     bsr.s    DM_setup
  639.     add.l    #16,a0
  640.     lea    channel2(pc),a6
  641.     bsr.s    DM_setup
  642.     add.l    #16,a0
  643.     lea    channel3(pc),a6
  644.     bsr.s    DM_setup
  645.     add.l    #16,a0
  646.     lea    channel4(pc),a6
  647.     bsr.s    DM_setup
  648.     move.w    #$8001,channel1+c_dma
  649.     move.w    #$8002,channel2+c_dma
  650.     move.w    #$8004,channel3+c_dma
  651.     move.w    #$8008,channel4+c_dma
  652.     move.l    track1(pc),channel1+c_track
  653.     move.l    track2(pc),channel2+c_track
  654.     move.l    track3(pc),channel3+c_track
  655.     move.l    track4(pc),channel4+c_track
  656.     rts
  657.  
  658. DM_setup:
  659.     move.l    a0,c_hardware(a6)
  660.     move.w    #16,h_length(a0)
  661.     clr.w    h_volume(a0)
  662.     move.l    #safe_zero,c_sounddata(a6)
  663.     clr.w    c_frequency(a6)
  664.     move.l    snd_table(pc),d0
  665.     add.l    #16,d0
  666.     move.l    d0,c_sound_table(a6)
  667.     clr.w    c_sound_table_cnt(a6)
  668.     clr.w    c_track_cnt(a6)
  669.     move.l    blocks(pc),c_block(a6)
  670.     clr.l    c_block_cnt(a6)
  671.     clr.l    c_vibrator_wait(a6)
  672.     clr.l    c_vibrator_freq(a6)
  673.     clr.l    c_frequency_data(a6)
  674.     move.l    #1,c_sustain(a6)
  675.     clr.l    c_bendrate_freq(a6)
  676.     clr.l    c_arpeggio_cnt(a6)
  677.     clr.w    c_effect_data(a6)
  678.     rts
  679.  
  680. ; ----  EFFECT ROUTINES  ----
  681.  
  682. eff0:
  683.     rts
  684. eff1:
  685.     and.b    #15,d0            ; set play speed
  686.     beq.s    eff1_exit
  687.     move.b    d0,play_speed
  688. eff1_exit:
  689.     rts
  690. eff2:
  691.     sub.w    d0,c_bendrate_freq(a6)    ; slide freq up
  692.     rts
  693. eff3:
  694.     add.w    d0,c_bendrate_freq(a6)    ; slide freq down
  695.     rts
  696. eff4:
  697. *    tst.b    d0
  698. *    beq    led_off
  699. *    bset    #1,$bfe001        ; led on/off
  700. *    rts
  701. led_off:
  702. *    bclr    #1,$bfe001
  703.     rts
  704. eff5:
  705.     move.b    d0,s_vibrator_wait(a5)    ; set vibrator wait
  706.     rts
  707. eff6:
  708.     move.b    d0,s_vibrator_step(a5)    ; set vibrator step
  709.     rts
  710. eff7:
  711.     move.b    d0,s_vibrator_length(a5); set vibrator length
  712.     rts
  713. eff8:
  714.     move.b    d0,s_bendrate(a5)    ; set bendrate
  715.     rts
  716. eff9:
  717.     move.b    d0,s_portamento(a5)    ; set portamento
  718.     rts
  719. effA:
  720.     cmp.b    #65,d0
  721.     bmi.s    effA_con
  722.     move.b    #64,d0
  723. effA_con:
  724.     move.b    d0,s_volume(a5)        ; set volume
  725.     rts
  726. effB:
  727.     move.b    d0,s_arpeggio(a5)    ; set arp 1
  728.     rts
  729. effC:
  730.     move.b    d0,s_arpeggio+1(a5)    ; set arp 2
  731.     rts
  732. effD:
  733.     move.b    d0,s_arpeggio+2(a5)    ; set arp 3
  734.     rts
  735. effE:
  736.     move.b    d0,s_arpeggio+3(a5)    ; set arp 4
  737.     rts
  738. effF:
  739.     move.b    d0,s_arpeggio+4(a5)    ; set arp 5
  740.     rts
  741. eff10:
  742.     move.b    d0,s_arpeggio+5(a5)    ; set arp 6
  743.     rts
  744. eff11:
  745.     move.b    d0,s_arpeggio+6(a5)    ; set arp 7
  746.     rts
  747. eff12:
  748.     move.b    d0,s_arpeggio+7(a5)    ; set arp 8
  749.     rts
  750. eff13:
  751.     move.b    d0,s_arpeggio(a5)    ; set arp 1 / 5
  752.     move.b    d0,s_arpeggio+4(a5)
  753.     rts
  754. eff14:
  755.     move.b    d0,s_arpeggio+1(a5)    ; set arp 2 / 6
  756.     move.b    d0,s_arpeggio+5(a5)
  757.     rts
  758. eff15:
  759.     move.b    d0,s_arpeggio+2(a5)    ; set arp 3 / 7
  760.     move.b    d0,s_arpeggio+6(a5)
  761.     rts
  762. eff16:
  763.     move.b    d0,s_arpeggio+3(a5)    ; set arp 4 / 8
  764.     move.b    d0,s_arpeggio+7(a5)
  765.     rts
  766. eff17:
  767.     cmp.b    #65,d0            ; set attack step
  768.     bmi.s    eff17_con
  769.     move.b    #64,d0
  770. eff17_con:
  771.     move.b    d0,s_attack_step(a5)
  772.     rts
  773. eff18:
  774.     move.b    d0,s_attack_delay(a5)    ; set attack delay
  775.     rts
  776. eff19:
  777.     cmp.b    #65,d0            ; set decay step
  778.     bmi.s    eff19_con
  779.     move.b    #64,d0
  780. eff19_con:
  781.     move.b    d0,s_decay_step(a5)
  782.     rts
  783. eff1A:
  784.     move.b    d0,s_decay_delay(a5)    ; set decay delay
  785.     rts
  786. eff1B:
  787.     move.b    d0,s_sustain(a5)    ; set sustain byte 1
  788.     rts
  789. eff1C:
  790.     move.b    d0,s_sustain+1(a5)    ; set sustain byte 2
  791.     rts
  792. eff1D:
  793.     cmp.b    #65,d0            ; set release step
  794.     bmi.s    eff1D_con
  795.     move.b    #64,d0
  796. eff1D_con:
  797.     move.b    d0,s_release_step(a5)
  798.     rts
  799. eff1E:
  800.     move.b    d0,s_release_delay(a5)    ; set release delay
  801.     rts
  802.  
  803.  
  804. effect_table:
  805.     dc.l    eff0,eff1,eff2,eff3,eff4,eff5,eff6,eff7
  806.     dc.l    eff8,eff9,effA,effB,effC,effD,effE,effF
  807.     dc.l    eff10,eff11,eff12,eff13,eff14,eff15,eff16,eff17
  808.     dc.l    eff18,eff19,eff1A,eff1B,eff1C,eff1D,eff1E,eff0
  809.  
  810. play_speed:
  811.     dc.b    speed
  812.     even
  813. safe_zero:
  814.     dcb.b    16,0
  815.  
  816. freq_table:
  817.  dc.w    0000,6848,6464,6096,5760,5424,5120,4832,4560,4304,4064,3840
  818.  dc.w    3616,3424,3232,3048,2880,2712,2560,2416,2280,2152,2032,1920
  819.  dc.w    1808,1712,1616,1524,1440,1356,1280,1208,1140,1076,0960,0904
  820.  dc.w    0856,0808,0762,0720,0678,0640,0604,0570,0538,0508,0480,0452
  821.  dc.w    0428,0404,0381,0360,0339,0320,0302,0285,0269,0254,0240,0226
  822.  dc.w    0214,0202,0190,0180,0170,0160,0151,0143,0135,0127,0120,0113
  823.  dc.w    0113,0113,0113,0113,0113,0113,0113,0113,0113,0113,0113,0113
  824.  
  825. channel1:
  826.     dc.l    $dff0a0        ; hardware pointer
  827.     dc.w    $8001        ; DMA value
  828.     dc.l    0        ; instrument pointer
  829.     dc.w    0        ; frequency
  830.     dc.l    0        ; sound table pointer
  831.     dc.b    0        ; sound table counter
  832.     dc.b    0        ; sound table delay
  833.     dc.l    0        ; track pointer
  834.     dc.w    0        ; track counter
  835.     dc.l    0        ; block pointer
  836.     dc.l    0        ; block counter
  837.     dc.b    0        ; vibrator wait
  838.     dc.b    0        ; vib length
  839.     dc.b    0        ; vib position
  840.     dc.b    0        ; vib length + & - (compare)
  841.     dc.w    0        ; vib add freq
  842.     dc.w    0        ; old freq for portamento
  843.     dc.b    0        ; freq_dat
  844.     dc.b    0        ; actual volume
  845.     dc.b    0        ; attack delay
  846.     dc.b    0        ; decay delay
  847.     dc.w    0        ; sustain
  848.     dc.b    0        ; release delay
  849.     dc.b    1        ; play speed
  850.     dc.w    0        ; bendrate freq
  851.     dc.b    0        ; transpose
  852.     dc.b    0        ; status
  853.     dc.b    0        ; arpeggio counter
  854.     dc.b    0        ; arpeggio data
  855.     dc.b    0        ; arpeggio on/off
  856.     dc.b    0        ; effect number
  857.     dc.b    0        ; effect data
  858.     even
  859.  
  860. channel2:
  861.     dcb.b    channel2-channel1,0
  862. channel3:
  863.     dcb.b    channel2-channel1,0
  864. channel4:
  865.     dcb.b    channel2-channel1,0
  866.  
  867. track1:
  868.     dc.l    0
  869. track2:
  870.     dc.l    0
  871. track3:
  872.     dc.l    0
  873. track4:
  874.     dc.l    0
  875. blocks:
  876.     dc.l    0
  877.  
  878. snd_table:
  879.     dcb.l    20,0
  880.  
  881. ;data:
  882.     dcb.b    2,0
  883.  
  884.